﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace GVSample
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindGV();
        }

        private void BindGV()
        {
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["newconn"].ConnectionString))
            {

                try
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("SELECT * FROM [Production].[Product]", conn);
                    SqlDataReader reader;
                    reader = cmd.ExecuteReader();
                    gv.DataSource = reader;
                    gv.DataBind();
                }
                 catch(Exception ex)
                {

                     Response.Write("Error:" + ex.Message.ToString());

                }
                finally 
                {
                    conn.Close();
                }


            }
        
        
        }
    }
}
